package com.changgou.search.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.search.service.ESManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: HuangFu
 * @Date: 2020/2/1 11:53
 * @Description: 商品检索控制层
 */
@RestController
@RequestMapping("/manager")
public class ESManagerController {

    @Autowired
    private ESManagerService esManagerService;

    @GetMapping("/create")
    public Result create(){
        esManagerService.createIndexAndMappering();
        return new Result(true, StatusCode.OK,"创建索引成功");
    }

    /**
     * 导入全部索引数据
     * @return
     */
    @GetMapping("/importall")
    public Result importAll(){
        esManagerService.importAll();
        return new Result(true, StatusCode.OK,"创建索引成功");
    }

    @GetMapping("/deleteall")
    public Result deleteAll(){
        esManagerService.deleteAll();
        return new Result(true, StatusCode.OK,"清空索引成功");
    }
}
